Python Script
A Python Script allows you to write a script for manipulating components, commands and the application using Python programming language (stackless, version 2.7).
Properties
Name | Description |
Name | Defines the name of the script. |
Script | Allows you to view and edit the script in an editor. |
Editor
In order to access the script editor, do one of the following:
- In the Component Graph panel, Component Node Tree, find the Python Script behavior you want to edit, and then double-click that behavior.
- In the Properties panel, click Open In Editor.
The script editor displays line numbers, expand/collapse options for code blocks, and a toolbar.
Name | Description |
Compile | Compiles the script into Python bytecode, which can then be executed by the application. That is, you are saving the script, and this should always be done before you run a simulation. Note at compiling messages, errors and any exceptions will be printed in the Output panel and the script is automatically compiled when you exit its editor. |
Trace Execution | Tracks the execution of the script during a simulation to allow you to view which line of code is being executed at a given moment. Generally, tracing is used to debug a script (find and resolve errors) as well as to understand how a script performs based on the conditions of your layout. |
Run to cursor | Runs the script until it reaches the current line of the cursor/caret in the editor. Generally, running to cursor is used to debug a script in which you are testing if the script can reach a certain line of code. |
Step 1 line | Runs the script so that the current line of code is executed in order to move the script one step forward in its execution. Generally, stepping is used to walk through the sequence of a script one line at a time in order to verify expected outcomes. |
Snippets | Allows you to insert a code snippet in the script. |
Cut | Removes selected code from the script, and then copies that code to the clipboard. |
Copy | Copies selected code in the script to the clipboard. |
Paste | Inserts code from the clipboard to the script. |
Undo | Cancels the last edit performed in the script. |
Redo | Executes the last undone edit performed in the script. |
Background | Toggles the background color and syntax highlighting. |
Find | Allows you to search the script for items matching keywords in the Search box. |
Find Next | Moves the cursor to the next search result in the script. |
Find Previous | Moves the cursor to the previous search result in the script. |
Highlight All Matches | Highlights all search results in the script. |
Clear Highlights | Removes the highlights assigned to search results in the script. |
Snippets
The initial content of the editor contains a code snippet that allows you to use the properties, methods and events of the script's behavior:
from vcScript import * def OnSignal( signal ): pass def OnRun(): pass |
If the text area is active, you can press CTRL+J to insert a snippet of code.
Word Completion
The editor allows you to use autocomplete for certain types of cases. For example, if the text area is active, you can press CTRL+SPACEBAR to display options for completing a line of code.
If you use autocomplete, you may be able to read documentation about the added item.